package com.example.management.mapper;

import com.example.management.pojo.Building;
import com.example.management.pojo.Dormitory;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BuildingMapper {
    @Select("select * from building")
    List<Building> getAllBuilding();

    @Select("select * from dormitory where building_tag=#{tag}")
    List<Dormitory> selectDormitoryByTag(Building building);

    @Select("select * from building where number=#{number}")
    Building selectBuildingByNum(Integer number);

    @Update("update building set tag=#{tag},position=#{position} " +
            "where number=#{number}")
    void updateBuilding(Building building);

    @Delete("delete from building where number=#{number}")
    void deleteBuilding(@Param("number") Integer number);

    @Insert("insert into building(number, tag, position)" +
            "VALUE(#{number},#{tag},#{position})")
    void insertBuilding(Building building);
}
